package com.base.utils;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * 创建集合的几种方式
 */
public class ListUtil {

    public static void main(String[] args) {

        List<String> strList1 = new ArrayList<>();

        List<String> strList2 = Arrays.asList("JDK6", "JDK7");

        List<String> strList3 = Collections.nCopies(3, "apple");

        List<String> strList4 = new ArrayList<String>() {{
            add("Tom");
            add("Sally");
        }};

        // JDK8
        List<String> strList5 = Stream.of("blue", "red", "yellow").collect(Collectors.toList());

        //JDK9
        //List<String> strList6 = List.of("A","B","C");

    }
}
